package com.wealth.system.repository.impl;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import com.wealth.system.entity.User;
import com.wealth.system.repository.UserCustomerDao;

/**
 * 
 * @author chan
 */

public class UserDaoImpl implements UserCustomerDao {

	@PersistenceContext
 	private EntityManager em;
	
	/** HQL多对多查询 */
	@Override
	public User findCorpAmin(Long corpid) throws Exception {
		String hql = "select u from User u join u.roleList b where u.corp.id=:corpid and b.id = 2L  ";
		Query query = em.createQuery(hql);
		query.setParameter("corpid", corpid);
		User user = (User) query.getSingleResult();
		return user;
	}
}


